package cn.itcast.hotel.listener;

import cn.itcast.hotel.content.Content;
import cn.itcast.hotel.service.IHotelService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class mqListener {

    @Autowired
    private IHotelService hotelService;

    @RabbitListener(queues = Content.HOTEL_INSERT_QUEUE)
    public void insertQueue(Long id){
        hotelService.addById(id);
        System.out.println("add");
    }

    @RabbitListener(queues = Content.HOTEL_DELETE_QUEUE)
    public void deleteQueue(Long id){
        hotelService.deleteById(id);
        System.out.println("delete");
    }
}
